
myCol = function(){
	num <- seq(1,100)
	num2 <- (2 - log10(num))/2
	rgb(num2, num2, 1)
}

myCol = function(){
	colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan","#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000"), bias=2)( 100 )
	#colorRampPalette(c("blue", "white", "red"))(100)
	#colorRampPalette(c("#FFFFD4", "#FED98E", "#FE9929", "#D95F0E", "#993404"),space = "Lab")(100)
}



library(fields)
image.plot2 = function(mat,title){
	d = dim(mat)[1]
	n = dim(mat)[2]
	mat.rev = t(mat[d+1-c(1:d), ])
	image.plot(1:n , 1:d, mat.rev, col = myCol(), axes = F, xlab = "", ylab = "", main = title)
	box()

}


data <- read.table(file.choose(), header=F)
v <- data$V1
saturate <- 300
v <- ifelse(v > saturate, saturate,v)


mat <- matrix(v, nrow=sqrt(length(v)), byrow=T)
image.plot2(mat, "1% treat 40kb")

